<?php
/**
 * Created by PhpStorm.
 * User: Hasee
 * Date: 2020/3/30
 * Time: 1:07
 */
//判断内容是否有填写
//考虑数据是否合法
$name=addslashes($_POST['name']);
$class=(int)($_POST['class']);
$age=(int)($_POST['age']);
$mb=addslashes($_POST['mb']);
$sql="INSERT INTO `test`.`student` (
`uid` ,
`name` ,
`class` ,
`studentMb` ,
`age`
)
VALUES (
    NULL , '$name', $class, $age, '$mb'
)";
//echo $sql;
$bool=mysqli_query($mysql,$sql);
$index=mysqli_insert_id($mysql);//返回最后一条插入语句产生的自增 ID
if ($bool)
{
    echo json_encode(array(
        'statu'=>200,
        'info'=>$index
    ));
}else{
    echo json_encode(array(
        'statu'=>400,
        'info'=>'on'
    ));
}
//var_export($_POST);